#include<bits/stdc++.h>
using namespace std;
int n,m,L,V;
struct car{
    int v,a,d;
    float l,r;
    vector<int> dted;
};
vector<car> c;
int det[100001];

void solve(){
    c.clear();
    cin>>n>>m>>L>>V;
    for(int i=1;i<=n;i++){
        int v,a,d;
        cin>>d>>v>>a;
        if(a<=0&&v<=V)continue;
        else{
            car t;t.d=d;t.v=v;t.a=a;
            if(v<=V&&a>0){
                t.l=d+(V*V-v*v)/2/a+0.001;
                t.r=L;
                if(t.l>=L)continue;
            }else if(v>V&&a>=0){
                t.l=d;
                t.r=L;
            }else if(v>V&&a<0){
                t.l=d;
                t.r=d+(V*V-v*v)/2/a-0.001;
                if(t.r>L)t.r=L;
            }
            c.push_back(t);
        }
    }
    for(int i=1;i<=m;i++){cin>>det[i];}
    
    int ans1=0;
    for(int i=0;i<c.size();i++){
        for(int j=1;j<=m;j++){
            if(c[i].l<=det[j]&&c[i].r>=det[j]){
                if(c[i].dted.empty())ans1++;
                c[i].dted.push_back(i);
            }
        }
    }
    cout<<ans1<<" ";
    
    int ans2=0;
    for(int i=0;i<c.size();i++){
        if(ans2<c[i].dted.size())ans2=c[i].dted.size();
    }
    cout<<ans2-1<<endl;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    cin>>T;
    while(T--)solve();
    return 0;
}